package day1.homeWork;

import java.io.File;
import java.io.IOException;

public class FileTest {
    public static void main(String[] args) throws IOException {
        File f = new File("d://HelloWord.txt");
        f.createNewFile();
        System.out.println("f是文件吗? :" + f.isFile());
        System.out.println("f是目录吗? :" + f.isDirectory());

        File f2 = new File("d://IOTest");
        boolean b = f2.exists();
        if (b){
            System.out.println("目录已存在!");
        }else {
            System.out.println("目录不存在，创建目录!");
            if (f2.mkdir()){
                System.out.println("目录创建成功!");
            }else {
                System.out.println("目录创建失败!");
            }
        }
        f.renameTo(new File("d://IOTest//HelloWord.txt"));
        String[] names = f2.list();
        for (String s : names) {
            System.out.println(s);
        }
    }
}